Build extract-strings tool for build system
authorHib Eris <hib@hiberis.nl>
Sat, 11 May 2013 14:57:39 +0000 (16:57 +0200)
committerHib Eris <hib@hiberis.nl>
Mon, 13 May 2013 15:07:46 +0000 (17:07 +0200)
This fixes cross compiling where build system != host system.

https://bugzilla.gnome.org/show_bug.cgi?id=699690

configure.ac
gtk/Makefile.am
m4/ax_prog_cc_for_build.m4
m4/pkg_config_for_build.m4 [new file with mode: 0644]

index 9713015821a933640aaa06843011c5bb6a2ecec0..9b90e3800985bf3eea3261ca1e0d06a0c5d9c2ff 100644 (file)
@@ -684,6 +684,12 @@ AM_PATH_GLIB_2_0(glib_required_version, :,
 *** GLIB is always available from ftp://ftp.gtk.org/pub/gtk/.]),
   gobject gmodule-no-export)
 
+PKG_PROG_PKG_CONFIG_FOR_BUILD
+GLIB_CFLAGS_FOR_BUILD=`$PKG_CONFIG_FOR_BUILD --cflags glib-2.0 gobject-2.0 gmodule-no-export-2.0`
+GLIB_LIBS_FOR_BUILD=`$PKG_CONFIG_FOR_BUILD --libs glib-2.0 gobject-2.0 gmodule-no-export-2.0`
+AC_SUBST(GLIB_CFLAGS_FOR_BUILD)
+AC_SUBST(GLIB_LIBS_FOR_BUILD)
+
 dnl Check for bind_textdomain_codeset, including -lintl if GLib brings it in.
 dnl
 gtk_save_LIBS=$LIBS
index 296ef00ec418ae86ff79dc5f42bb4a1d482780af..21ac74c3d366ff53e0dc4d3587e23b3b6a697434 100644 (file)
@@ -1128,8 +1128,8 @@ template_headers = $(COMPOSITE_TEMPLATES:.ui=.ui.h)
 
 MAINTAINERCLEANFILES += $(template_headers)
 
-%.ui.h: %.ui extract-strings$(EXEEXT)
-       $(AM_V_GEN) ./extract-strings$(EXEEXT) $< > $@
+%.ui.h: %.ui extract-strings$(BUILD_EXEEXT)
+       $(AM_V_GEN) ./extract-strings$(BUILD_EXEEXT) $< > $@
 
 #
 # rules to generate built sources
@@ -1401,10 +1401,15 @@ endif
 gtk_launch_LDADD = $(LDADDS)
 gtk_launch_SOURCES = gtk-launch.c
 
-noinst_PROGRAMS = extract-strings
-
-extract_strings_SOURCES = extract-strings.c
-extract_strings_LDADD = $(GLIB_LIBS)
+# The extract_strings tool is a build utility that runs on the build system.
+extract_strings_sources = extract-strings.c
+extract_strings_cppflags =
+extract_strings_cflags = $(GLIB_CFLAGS_FOR_BUILD)
+extract_strings_ldadd = $(GLIB_LIBS_FOR_BUILD)
+extract-strings$(BUILD_EXEEXT): $(extract_strings_sources)
+       @rm -f extract-strings$(BUILD_EXEEXT)
+       $(AM_V_CCLD)$(CC_FOR_BUILD) $(extract_strings_cppflags) $(CPPFLAGS_FOR_BUILD) $(extract_strings_cflags) $(CFLAGS_FOR_BUILD) $^ $(LDFLAGS_FOR_BUILD) $(extract_strings_ldadd) $(LIBS_FOR_BUILD) -o $@
+EXTRA_DIST += $(extract_strings_sources)
 
 .PHONY: files test test-debug
 
index 96cd98ac9b23364d3d43deaf9a362f572c0b0f33..c2adede872a0dd2db9b225872b41c82bc3f214be 100644 (file)
@@ -57,6 +57,7 @@ pushdef([CPP], CPP_FOR_BUILD)dnl
 pushdef([CFLAGS], CFLAGS_FOR_BUILD)dnl
 pushdef([CPPFLAGS], CPPFLAGS_FOR_BUILD)dnl
 pushdef([LDFLAGS], LDFLAGS_FOR_BUILD)dnl
+pushdef([LIBS], LIBS_FOR_BUILD)dnl
 pushdef([host], build)dnl
 pushdef([host_alias], build_alias)dnl
 pushdef([host_cpu], build_cpu)dnl
@@ -98,6 +99,7 @@ popdef([host_vendor])dnl
 popdef([host_cpu])dnl
 popdef([host_alias])dnl
 popdef([host])dnl
+popdef([LIBS])dnl
 popdef([LDFLAGS])dnl
 popdef([CPPFLAGS])dnl
 popdef([CFLAGS])dnl
diff --git a/m4/pkg_config_for_build.m4 b/m4/pkg_config_for_build.m4
new file mode 100644 (file)
index 0000000..0422f48
--- /dev/null
@@ -0,0 +1,20 @@
+# PKG_PROG_PKG_CONFIG_FOR_BUILD([MIN-VERSION])
+# ----------------------------------
+AC_DEFUN([PKG_PROG_PKG_CONFIG_FOR_BUILD],
+[m4_pattern_allow([^PKG_CONFIG_FOR_BUILD$])
+AC_ARG_VAR([PKG_CONFIG_FOR_BUILD], [path to build system's pkg-config utility])
+
+if test "x$ac_cv_env_PKG_CONFIG_FOR_BUILD_set" != "xset"; then
+       AC_PATH_PROG([PKG_CONFIG_FOR_BUILD], [pkg-config])
+fi
+if test -n "$PKG_CONFIG_FOR_BUILD"; then
+       _pkg_for_build_min_version=m4_default([$1], [0.9.0])
+       AC_MSG_CHECKING([build system's pkg-config is at least version $_pkg_min_version])
+       if $PKG_CONFIG_FOR_BUILD --atleast-pkgconfig-version $_pkg_min_version; then
+               AC_MSG_RESULT([yes])
+       else
+               AC_MSG_RESULT([no])
+               PKG_CONFIG_FOR_BUILD=""
+       fi
+fi[]dnl
+])# PKG_PROG_PKG_CONFIG_FOR_BUILD